package com.leiyk.rateLimiter.strategy.impl;

import com.leiyk.rateLimiter.enums.RateLimitObjectEnum;
import com.leiyk.rateLimiter.strategy.inxterfaces.IRateLimiterStrategy;
import jakarta.annotation.Resource;
import org.springframework.data.redis.core.StringRedisTemplate;
import java.util.concurrent.TimeUnit;

/**
 * @Description: 简单计时器限流策略
 * @Author: leiyk6
 * @Date: 2024/7/3 8:56
 */

public class SimpleCounterStrategy implements IRateLimiterStrategy {

    private Integer time;


    private TimeUnit timeUnit;


    private Integer maxRequestCount;

    SimpleCounterStrategy(Integer time, TimeUnit timeUnit, Integer maxRequestCount ){
        this.time = time;
        this.timeUnit = timeUnit;
        this.maxRequestCount = maxRequestCount ;

    }


    @Resource
    private StringRedisTemplate stringRedisTemplate;




    @Override
    public boolean allowRequest(RateLimitObjectEnum limitObjectEnum) {

        return true;
    }


    public static SimpleCounterStrategy  getInstance(Integer time, TimeUnit timeUnit, Integer maxRequestCount) {
        return new SimpleCounterStrategy(time, timeUnit, maxRequestCount);
    }



}
